﻿using System;
using System.Windows.Forms;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Tests.Forms
{
	public partial class FrameXmlTestBenchForm : Form
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="FrameXmlTestBenchForm"/> class.
		/// </summary>
		/// <param name="control">The control.</param>
		/// <param name="timerEnabled">if set to <c>true</c> [timer enabled].</param>
		public FrameXmlTestBenchForm(Control control, bool timerEnabled)
		{
			if (control == null)
				throw new ArgumentNullException("control");

			InitializeComponent();

			// Add Ui control to test bench panel and dock it
			panelTestBench.Controls.Add(control);
			control.Dock = DockStyle.Fill;

			timerTimeout.Enabled = timerEnabled;

			BringToFront();
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="FrameXmlTestBenchForm"/> class.
		/// </summary>
		/// <param name="control">The control.</param>
		public FrameXmlTestBenchForm(Control control)
			: this(control, true)
		{
		}

		/// <summary>
		/// Handles the Tick event of the timerTimeout control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void timerTimeout_Tick(object sender, EventArgs e)
		{
			buttonAccept.PerformClick();
		}
	}
}